<?php

namespace App\Events\OpenShop;

use App\Models\OpenShop\InvestmentPromotion\OpenShopSignOrderModel;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class OrderClosedEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public ?OpenShopSignOrderModel $order = null;
    // 1-延迟自动关闭，2-主动作废
    public int $type = 1;
    // 操作人的uid，0为系统
    public int $uid = 0;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(OpenShopSignOrderModel $order, int $type, int $uid = 0)
    {
        $this->order = $order;
        $this->type  = $type;
        $this->uid   = $uid;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
